﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class PhpscupApp extends BaseApp
{
    function index()
    { 
	    $setlang = '';
		if(isset($_GET['langid']))
		{
	    $setlang = $_GET['langid']; 		
		}

        if(!empty($setlang))
		{
				  if(preg_match("/[.\/]/",$setlang))
		          {
		            $GLOBALS['Lang']->_lang_tp = LANG;
		  
                  } 
				  else
				  {
				  $GLOBALS['Lang']->_lang_tp = $setlang;				  
				  }
		          $GLOBALS['Lang']->_set_lang($GLOBALS['Lang']->_lang_tp);
		}
		$GLOBALS['Lang']->_get_lang('default');	
		
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
		
        $this->assign('navigation', $nav->_get_nav());	

		
        $this->assign('category_nav_data', $nav->curnav());

	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);			

        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);	
		
		$TB_new = &$this->_model('new');				
		$data_index_new = $TB_new->inindex();		
        $this->assign('data_index_new', $data_index_new);		

		$data_reindex_new = $TB_new->reindex();		
        $this->assign('data_reindex_new', $data_reindex_new);	


		$TB_job = &$this->_model('job');				
		$data_index_job = $TB_job->inindex();		
        $this->assign('data_index_job', $data_index_job);	
		
		$TB_prot = &$this->_model('prot');				
		$data_index_prot = $TB_prot->inindex();		
        $this->assign('data_index_prot', $data_index_prot);
						
		$data_reindex_prot = $TB_prot->reindex();		
        $this->assign('data_reindex_prot', $data_reindex_prot);	

        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);

        $link_data = @include(ROOT_PATH . '/data/cache/links_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('link_data', $link_data);
	    
        $this->assign('view_charset', VIEW_CHARSET);
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 	
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
						
        $this->assign('site_url', SITE_URL);
				
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);		

		
        $this->display('index.view.html');
    }


    function links()
    { 
		
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	

	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);			

        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);	

		$TB_new = &$this->_model('new');				
		$data_index_new = $TB_new->reindex();		
        $this->assign('data_index_new', $data_index_new);		
		
		$TB_prot = &$this->_model('prot');				
		$data_index_prot = $TB_prot->reindex();		
        $this->assign('data_index_prot', $data_index_prot);		
		
        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);

        $link_data = @include(ROOT_PATH . '/data/cache/links_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('link_data', $link_data);
	    
        $this->assign('view_charset', VIEW_CHARSET);
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 	
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
						
        $this->assign('site_url', SITE_URL);
				
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
		
        $this->display('links.view.html');
    }

    function sitemap()
    {		
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	

	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);
			
	 	$categorydata_prot = & $GLOBALS['SCup']->_get_category_data('prot'); 		
        $this->assign('categorydata_prot', $categorydata_prot);			
	 	$categorydata_new = & $GLOBALS['SCup']->_get_category_data('new'); 		
        $this->assign('categorydata_new', $categorydata_new);	
	    $TB_alonepage = &$this->_model('alonepage');		
		$data = $TB_alonepage->show();				
        $this->assign('lw_data', $data['data']);
		
        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);	

		$TB_new = &$this->_model('new');				
		$data_index_new = $TB_new->reindex();		
        $this->assign('data_index_new', $data_index_new);		
		
		$TB_prot = &$this->_model('prot');				
		$data_index_prot = $TB_prot->reindex();		
        $this->assign('data_index_prot', $data_index_prot);		
		
        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);

        $link_data = @include(ROOT_PATH . '/data/cache/links_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('link_data', $link_data);
	    
        $this->assign('view_charset', VIEW_CHARSET);
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 	
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
						
        $this->assign('site_url', SITE_URL);
				
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
		
        $this->display('sitemap.view.html');
    }



    function yzimage()
    {		
      include(ROOT_PATH ."/lib/image.lib.php");
      $string_yzimg=check_rand(4);
      set_cookie("yzImgNum","$string_yzimg", 0,COOKIE_PATH, COOKIE_DOMAIN, false);
	  $GLOBALS['SCup']->SCup_user_msg['data']['yzImgNum'] = $string_yzimg; 

      Image:: check_img($string_yzimg); 
    }
	
/*<SCRIPT LANGUAGE='JavaScript' src='http://localhost/phpscup_v1.8.2_utf-8_test/?app=phpscup&act=ad&id=1'></SCRIPT>*/		
     function ad()
    {
		$id	= intval($_GET['id']);		
		$tempdata = $this->get_ad_data();
		$data = $tempdata[$id];
   if(empty($data['left']['picurl'])||empty($data['right']['picurl']))
   {
	echo "";
	exit;   
   }  		
       $l_src = SITE_URL.'/'.UPFILE_PATH.'/'.$data['left']['picurl'];
   $L_Types = '';
   $l_link = $data['left']['url'];
   $l_width = $data['left']['width'];
   $l_height = $data['left']['height'];
   $r_src = SITE_URL.'/'.UPFILE_PATH.'/'.$data['right']['picurl'];
   $R_Types = '';
   $r_link = $data['right']['url'];
   $r_width = $data['right']['width'];
   $r_height = $data['right']['height'];
   $webdb = SITE_URL.'/data';
	
			$show="
   var adLeftSrc = \"$l_src\"   //图片地址
   var adLeftFlash = \"$L_Types\"
   var adLeftHref = \"$l_link\"
   var adLeftWidth = '$l_width'
   var adLeftHeight = '$l_height'
   var adRightSrc = \"$r_src\"//图片地址
   var adRightFlash = \"$R_Types\"
   var adRightHref = \"$r_link\"
   var adRightWidth = '$r_width'
   var adRightHeight = '$r_height'
   var marginTop = 300 //在这里更改距离浏览器底端的高度
   var marginLeft = 5//在这里更改距离浏览器右端的高度
   var navUserAgent = navigator.userAgent
   function load(){
    judge();
    move();
   }
   function move() {
    judge();
    setTimeout(\"move();\",80)
   }
   function judge(){
    if (navUserAgent.indexOf(\"Firefox\") >= 0 || navUserAgent.indexOf(\"Opera\") >= 0) {
     if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adLeftHeight - marginTop + 'px';}
     if (adRightSrc != \"\") {
      document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adRightHeight - marginTop + 'px';
      document.getElementById(\"adRightFloat\").style.left = ((document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';
     } 
    }
    else{
     if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adLeftHeight - marginTop + 'px';}
     if (adRightSrc != \"\") {
      document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adRightHeight - marginTop + 'px';
      document.getElementById(\"adRightFloat\").style.left = ((document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';
     }
    }
    if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.left = marginLeft + 'px';}
   }
   
   
   
if (adLeftSrc != \"\") {
	if (adLeftFlash == \"flash\") {
		document.write(\"<div id=\\\"adLeftFloat\\\" style=\\\"position: absolute;width:\" + adLeftWidth + \";height:100px; font-size:12px;\\\"><div id='left_top'><img src=\\\"$webdb/images/close.gif\\\" width=\\\"12\\\" border=\\\"0\\\" height=\\\"12\\\" onMousedown=\\\"javascript:close_ad('left_top');void(0);\\\";>\");
    
		document.write(\"<div id=\\\"Float\\\" style=\\\"width:\" + adLeftWidth + \";\\\"><embed src=\\\"\" + adLeftSrc + \"\\\" quality=\\\"high\\\"  width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></embed></div></div>\");
		document.write(\"</div>\");
    }else{
		document.write(\"<div id=\\\"adLeftFloat\\\" style=\\\"position: absolute;width:\" + adLeftWidth + \";height:100px; font-size:12px;\\\"><img src=\\\"$webdb/images/close.gif\\\" width=\\\"12\\\" border=\\\"0\\\" height=\\\"12\\\" onMousedown=\\\"javascript:close_float_left();void(0);\\\";>\");
    
		document.write(\"<div id=\\\"Float\\\" style=\\\"width:\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\" target=_blank><img src=\\\"\" + adLeftSrc + \"\\\"  width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\"  border=\\\"0\\\" \></a></div>\");
		document.write(\"</div>\");
    }
}
   
   
   
if (adRightSrc != \"\") {
	if (adRightFlash == \"flash\") {
		document.write(\"<div id=\\\"adRightFloat\\\" style=\\\"position: absolute;width:\" + adRightWidth + \";height:100px; font-size:12px;text-align:right;\\\"><div id='right_top'><img src=\\\"$webdb/images/close.gif\\\" width=\\\"12\\\" border=\\\"0\\\" height=\\\"12\\\" onMousedown=\\\"javascript:close_ad('right_top');void(0);\\\";>\");
    
		document.write(\"<div id=\\\"Float\\\" style=\\\"width:\" + adRightWidth + \";\\\"><embed src=\\\"\" + adRightSrc + \"\\\" quality=\\\"high\\\"  width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></embed></div></div>\");
		document.write(\"</div>\");
    }else{
		document.write(\"<div id=\\\"adRightFloat\\\" style=\\\"position: absolute;width:\" + adRightWidth + \";height:100px; font-size:12px;text-align:right;\\\"><img src=\\\"$webdb/images/close.gif\\\" width=\\\"12\\\" border=\\\"0\\\" height=\\\"12\\\" onMousedown=\\\"javascript:close_float_right();void(0);\\\";>\");
    
		document.write(\"<div id=\\\"Float\\\" style=\\\"width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\" target=_blank><img src=\\\"\" + adRightSrc + \"\\\"   width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\"  border=\\\"0\\\"  \></a></div>\");
		document.write(\"</div>\");
    }
}
load();
function close_float_right(){
	document.getElementById(\"adRightFloat\").style.display=\"none\";
} 
function close_float_left(){
	document.getElementById(\"adLeftFloat\").style.display=\"none\";
}
function close_ad(d){
	document.getElementById(d).style.display=\"none\";
}
";
	echo "$show";
	exit;
    }	
    function get_ad_data()
    {
		return @include (ROOT_PATH . '/data/ad/ad.php');			
    }   
}






?>